package com.lily.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lily.ssm.mapper.MessageMapper;
import com.lily.ssm.model.Message;

@Service
public class MessageService {
	
	@Autowired
	private MessageMapper messageMapper;
	//分页获取所有留言
	public List<Message> getMessageList(int offset){
		return messageMapper.getAllMessage(offset);
	}
	
	//根据messageId 获取Message信息
	public Message getMessage(int messageId){
		return messageMapper.selectByPrimaryKey(messageId);
	}
	
	//添加回复内容
	public int updateMessage(Message message){
		return messageMapper.updateByPrimaryKeySelective(message);
	}
	
	//查询共有多少条留言信息
	public int getCount(){
		return messageMapper.getCount();
	}
	
	//根据messageId删除留言
	public int deleteMessage(int messageId){
		return messageMapper.deleteByPrimaryKey(messageId);
	}
}
